const app = getApp()

import { throttle } from '../../utils/throttle.js'
import { HiddenCall } from '../../request/api'
const request = new HiddenCall
import filter from '../../mixins/filter'
Page({
/**
*  通信录页
* - @author           王磊
* - @date             2018-07-13
* searchList          通信录页面搜索字典
*/
  mixins: [filter],
  data: {
    searchList: [
      { name: '全部', key: '0' },
      { name: '部分', key: '1' }
    ]
  },
  onLoad: function (options) {
    // 调用通信录列表
    this.maillingList()
  },
  /**
   * 通讯录列表
   * author wl
   */
  maillingList: function() {
    request.maillingList().then((res) => {
      // 更新通信录列表渲染model
      this.setData({ maillingList: res.data.result })
    })
  },
  /**
   * 进入电话详情
   * author wl
   */
  entrMaillingDetail: throttle(function() {
    wx.navigateTo({
      url: '../mailing_detail/index'
    })
  }, 2000),
  /**
   * 进入短信详情
   * author wl
   */
  entrSms: throttle(function() {
    // 设置短信详情标志
    let data = {
      callType: "sms",
      detailType: "mineDetail"
    }
    // 跳转带入短信数据
    wx.navigateTo({
      url: `../mailing_detail/index?model=${JSON.stringify(data)}`
    })
  }, 2000)
})